package com.xingmei.springbootdemo.common;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ResultVo<T> {

    private Integer code;

    private String message;

    private T data;

    public static <T> ResultVo<T> success() {
        return ResultVo.<T>builder().code(ResultCodeEnum.SUCCESS.getCode()).message(ResultCodeEnum.SUCCESS.getMessage()).build();
    }

    public static <T> ResultVo<T> success(T data) {
        return ResultVo.<T>builder().code(ResultCodeEnum.SUCCESS.getCode()).message(ResultCodeEnum.SUCCESS.getMessage()).data(data).build();
    }

    public static <T> ResultVo<T> fail(ResultCodeEnum resultCodeEnum) {
        return ResultVo.<T>builder().code(resultCodeEnum.getCode()).message(resultCodeEnum.getMessage()).build();
    }
}
